import {
  visitorDetail
} from '../../../apis/visitor';

Page({
  data: {
    passport: {},
    id: '',
  },
  onLoad({
    id
  }) {
    this.getPassPort(id)
    this.setData({
      id
    })
  },
  async getPassPort(id) {
    const {
      code,
      data: passport
    } = await visitorDetail(id)
    // 检测接口调用的结果
    if (code !== 10000) return wx.utils.toast('获取通行证失败!')
    // 渲染通行证
    this.setData({
      ...passport
    })
  },
  onShareAppMessage() {
    return {
      title: '查看通行证',
      path: '/visitor_pkg/pages/passport/index?id=' + this.data.id,
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },

})